Ext.define('AccordionListExample.view.Main', {
    extend: 'Ext.Panel',
    xtype: 'main',
    config: {
        layout: 'card',
        groupByDay: true,
        loadingText: '加载中...',
        items: [
            {           xtype: 'panel',
                items: {
                    xtype: 'accordionlist',
                    store: Ext.create('AccordionListExample.store.Task'),
                    flex: 1,
                    itemId: 'task',
                    listeners: {
                        initialize: function () {
                            this.load();
                        }
                    }
                },
                layout: 'fit'
            }

        ],
        control: {

            'accordionlist': {
                leafitemtap: function (list, index, target, record) {
                    var value = record.get('text') || '';
                    if (value == '客户') {
                        var sessionCard = Ext.create('crm.view.CustomerList');
                        sessionCard.setPrevcard(this.down('accordionlist'), 'getcrmlist');
                        this.setActiveItem(sessionCard, 'slide');
                    }
                    if (value == '收藏') {
                        var sessionCard = Ext.create('crm.view.CustomerList');
                        sessionCard.setPrevcard(this.down('accordionlist'), 'getcrmfavor');
                        this.setActiveItem(sessionCard, 'slide');
                    }
                    if (value == '商机') {
                        var sessionCard = Ext.create('crm.view.OpportunityList');
                        sessionCard.setPrevcard(this.down('accordionlist'));
                        this.setActiveItem(sessionCard, 'slide');
                    }
                    if (value == '通讯录') {
                        var sessionCard = Ext.create('hrm.view.HumanList');
                        sessionCard.setPrevcard(this.down('accordionlist'));
                        this.setActiveItem(sessionCard, 'slide');
                    }
                }
            }
        }

    }
});
